package cn.tedu.shoot;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.ArrayList;


public class BossHero extends FlyingObject implements Award,EnemyBullets{
	protected int xspeed;
	protected int yspeed;//移动速度
	private int awardtype;
	public BossHero(){
		super(180,154);
		xspeed = 3;
		yspeed = 1;
		life = 100;
	}
	public void step() {
		y+=yspeed;
		x+=xspeed;
		if(y>=20){
			yspeed=0;
		}
		if(this.isDead()){
			xspeed=0;
		}
		if(x<=0 || x>=World.WIDTH-width){
			xspeed*=-1;
		}
	}
	int index = 0;
	int b=2,c=0;
   public BufferedImage getImage() {
	   if(isLife()) {
			return Images.bosshero[index++%2];
		}else if(isDead()) {
			BufferedImage img =  Images.bosshero[b];
			if(c++%40==0){
				b++;
			}
			if(b==Images.bosshero.length) {
			state = REMOVE;
		}
			return img;
		}
		return null;
	}
   /**重写getScore()得分*/
   public int getScore() {
	   return 100;
   }
   public ArrayList<BulletBoss> shootingShoot(){	   
	   int sum = 5; 
		int xStep = this.width/(sum+1);
		int yStep = 0;
		    BulletBoss[] bs = new BulletBoss[sum];
			ArrayList<BulletBoss> c = new ArrayList<>();
			for(int i=0;i<bs.length;i++){
				bs[i] = new BulletBoss(this.x+(i+1)*xStep,this.y+this.height+yStep);
				c.add(bs[i]);
			}
			return c;
  }
   public BossBlood addBlood(){
	   int xStep = this.width/2-81;
	   int yStep = 10;
	   BossBlood blood = new BossBlood(this.x+xStep,this.y-yStep);
	   return blood;
   }
   public int getAwardType(){
	   return awardtype;
   }
 class BossBlood{
	  private int x ;
	  private int y ;
	  private int width;
	  private int height;
	  private int xspeed;
		private int yspeed;
		public BossBlood(int x,int y) {
			width = 192;
			height =10;
			this.x = x;
			this.y = y;
			xspeed = 5;
			yspeed = 1;
		}

		public void step() {
			y+=yspeed;
			x+=xspeed;
			if(y>10){
				yspeed = 0;
			}
			if(isDead()){
				xspeed = 0;
			}
			if(x>=World.WIDTH-this.width ||x<=0){
				xspeed*=-1;
			}
		}

		public BufferedImage getImage() {
			if(isLife()){
			return Images.bloods[downLife()];
			}
			return null;
		}

		public void paintObject(Graphics g) {
			g.drawImage(getImage(), x, y, null);
		}

  }
}
